//
//  APIObject.m
//  YDdDemo
//
//  Created by 瞿伦平 on 2017/10/20.
//  Copyright © 2017年 瞿伦平. All rights reserved.
//

#import "APIObject.h"



@implementation NSString (AFDataDefine_Additions)
+(NSString*)strWithMoney:(float)value
{
    NSString * outNumber = [NSString stringWithFormat:@"%@",@(value)];
    return outNumber;
}

+(NSString*)strRMBWithMoney:(float)value
{
    NSString * outNumber = [NSString stringWithFormat:@"￥%@",@(value)];
    return outNumber;
}

@end




@implementation APIObject
+ (NSDictionary *)mj_replacedKeyFromPropertyName
{
    return @{@"msg": @"mssage",
             @"code": @"error",
             @"data": @"result"
             };
}


+(APIObject *)infoWithError:(NSError *)error
{
    APIObject *info = [[APIObject alloc] init];
    NSString *des = [error.userInfo objectWithKey:@"NSLocalizedDescription"];
    if (des.length > 0)
        info.msg = des;
    else
        info.msg       = @"网络请示失败，请检查网络";
    info.code = RESP_STATUS_NO;
    return info;
}

+(APIObject *)infoWithErrorMessage:(NSString *)errMsg
{
    APIObject *info = [[APIObject alloc] init];
    info.msg       = errMsg;
    info.code = RESP_STATUS_NO;
    return info;
}

+(APIObject *)infoWithReLoginErrorMessage:(NSString *)errMsg
{
    APIObject *info = [[APIObject alloc] init];
    info.msg       = errMsg.length>0 ? errMsg : @"请登录";
    info.code = RESP_STATUS_YES;
    return info;
}

-(void)setCode:(int)code
{
    _code = code;
    
    if (code == RESP_STATUS_RELOGIN)
        [self performSelector:@selector(startLogin) withObject:nil afterDelay:0.5];
}

-(void)startLogin
{
//    UIViewController *se = [UIViewController topViewController];
//    if (![se isKindOfClass:[LoginVC class]]) {
//        [LoginVC startPresent:se];
//    }
}
@end








@implementation OrderCommentObject

@end




@implementation FoodGoods
+ (NSDictionary *)mj_replacedKeyFromPropertyName
{
    return @{@"iD": @"id"};
}
@end

@implementation FoodCate
+ (NSDictionary *)mj_objectClassInArray
{
    return @{@"details": @"FoodGoods"};
}
@end





@implementation Shop
+ (NSDictionary *)mj_replacedKeyFromPropertyName
{
    return @{@"iD": @"id"};
}
@end


@implementation FoodShop
@end


@implementation Shippingfee
+ (NSDictionary *)mj_replacedKeyFromPropertyName
{
    return @{@"iD": @"id"};
}
@end

